﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FriendsNearby.Services.Entities;

namespace FriendsNearby.Services
{
    public class NewFriendNearbyStrategy
    {
        public static IList<string> GetNewFriendsNearby(IEnumerable<PersonNearby> friendsNearbyBefore, IEnumerable<PersonNearby> friendsNearbyNow)
        {
            IList<string> results = new List<string>();

            foreach (PersonNearby personNearbyNow in friendsNearbyNow)
            {
                bool alreadyNearby = false;
                if (friendsNearbyBefore != null)
                {
                    foreach (PersonNearby userNearbyBefore in friendsNearbyBefore)
                    {
                        if (personNearbyNow.FacebookUserID == userNearbyBefore.FacebookUserID)
                        {
                            alreadyNearby = true;
                            break;
                        }
                    }
                }
                if (!alreadyNearby)
                    results.Add(personNearbyNow.DisplayName);
            }
            return results;
        }
    }
}
